const http = require('http')
const fs = require('fs')
const path = require('path')
http.createServer(function(request, response){
  const host =  request.headers.host
  if(request.url==='/') {
    const html = fs.readFileSync(path.join(__dirname,'test.html'),'utf8')
    if (host==='test.com') {
      response.writeHead(200,{
        'Content-Type': 'text/html',
        'Set-Cookie':['id=123;max-age=2','name=yang;domain=test.com']
      })
    }
    response.end(html)
  }
}).listen(8888)